var express = require('express');
var router = express.Router();

const {
  login,
  verify,
  captcha,
  vcaptcha,
  findUsersByPage,
  addUser,
  findOneById,
  updateOneById,
  deleteOneById,
  editpwd,
  findLogsByPage,
  getData
} = require("../controller/users");
const { authFilter } = require("../middlewares/auth");

class UsersRouter {
  static initRouter() {
    router.post('/login', login);
    router.get('/verify', verify);
    router.get('/captcha', captcha);
    router.get('/captcha/:vcode', vcaptcha);
    router.get('/', authFilter, findUsersByPage);
    router.post('/0', authFilter, addUser);
    router.get('/getData', authFilter, getData);
    router.get('/getLogs', authFilter, findLogsByPage);
    router.get('/:id', authFilter, findOneById);
    router.put('/editpwd', authFilter, editpwd);
    router.put('/:id', authFilter, updateOneById);
    router.delete('/:id', authFilter, deleteOneById);
    return router;
  }
}
module.exports = UsersRouter.initRouter();